import React, { Component } from "react";
import PubSub from "pubsub-js";

export default class HeroSearch extends Component {
    render() {
        return (
            <div className="search">
                <input type="text" ref={(el) => (this.input = el)} />
                &nbsp;<button onClick={this.search}>搜索</button>
            </div>
        );
    }

    search = () => {
        //获得输入框的值
        let v = this.input.value;
        //
        PubSub.publish('keyword', v);
    };
}
